#include<vector>
using namespace std;


vector<vector<int>> ret;
vector<int> path;
bool check[7];

void dfs(vector<int> nums)
{
    if (path.size() == nums.size())
    {
        ret.push_back(path);
        return;
    }

    for (int i = 0; i < nums.size(); i++)
    {
        if (check[i] == false)
        {
            path.push_back(nums[i]);
            check[i] = true;
            dfs(nums);
            path.pop_back();
            check[i] = false;
        }
    }
}

vector<vector<int>> ret1;
vector<int> path1;
void dfs1(vector<int>& nums, int i)
{
    if (i == nums.size())
    {
        ret1.push_back(path1);
        return;
    }

    path1.push_back(nums[i]);
    dfs1(nums, i + 1);
    path1.pop_back();

    dfs1(nums, i + 1);
}
vector<vector<int>> subsets(vector<int>& nums) {
    dfs1(nums, 0);
    return ret1;
}


vector<vector<int>> permute(vector<int>& nums) {
    dfs(nums);
    return ret;
}

int main()
{
    vector<int> v{ 1,435,6472,2 };
    permute(v);
    subsets(v);

	return 0;
}